package ru.kipriz.todoly.api.entities;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>Copyright: Copyright (c) 2010</p>
 *
 * @author Andrey Volkov
 *         <br/>Date: 12/15/10
 */
public class ItemObject implements Entity
{
    long id;
    String content;
    int itemType;
    boolean checked;
    long projectId;
    long parentId;
    String path;
    boolean collapsed;
    String dateString;
    int dateStringPriority;
    String dueDate;
    RecurrenceObject recurrence;
    int itemOrder;
    int priority;
    List<ItemObject> children;
    String lastSyncedDateTime;

    public long getId()
    {
        return id;
    }

    public void setId(long id)
    {
        this.id = id;
    }

    public String getContent()
    {
        return content;
    }

    public void setContent(String content)
    {
        this.content = content;
    }

    public int getItemType()
    {
        return itemType;
    }

    public void setItemType(int itemType)
    {
        this.itemType = itemType;
    }

    public boolean isChecked()
    {
        return checked;
    }

    public void setChecked(boolean checked)
    {
        this.checked = checked;
    }

    public long getProjectId()
    {
        return projectId;
    }

    public void setProjectId(long projectId)
    {
        this.projectId = projectId;
    }

    public long getParentId()
    {
        return parentId;
    }

    public void setParentId(long parentId)
    {
        this.parentId = parentId;
    }

    public String getPath()
    {
        return path;
    }

    public void setPath(String path)
    {
        this.path = path;
    }

    public boolean isCollapsed()
    {
        return collapsed;
    }

    public void setCollapsed(boolean collapsed)
    {
        this.collapsed = collapsed;
    }

    public String getDateString()
    {
        return dateString;
    }

    public void setDateString(String dateString)
    {
        this.dateString = dateString;
    }

    public int getDateStringPriority()
    {
        return dateStringPriority;
    }

    public void setDateStringPriority(int dateStringPriority)
    {
        this.dateStringPriority = dateStringPriority;
    }

    public String getDueDate()
    {
        return dueDate;
    }

    public void setDueDate(String dueDate)
    {
        this.dueDate = dueDate;
    }

    public RecurrenceObject getRecurrence()
    {
        return recurrence;
    }

    public void setRecurrence(RecurrenceObject recurrence)
    {
        this.recurrence = recurrence;
    }

    public int getItemOrder()
    {
        return itemOrder;
    }

    public void setItemOrder(int itemOrder)
    {
        this.itemOrder = itemOrder;
    }

    public int getPriority()
    {
        return priority;
    }

    public void setPriority(int priority)
    {
        this.priority = priority;
    }

    public List<ItemObject> getChildren()
    {
        if (children == null)
        {
            children = new ArrayList<ItemObject>();
        }
        return children;
    }

    public void setChildren(List<ItemObject> children)
    {
        this.children = children;
    }

    public String getLastSyncedDateTime() {
        return lastSyncedDateTime;
    }

    public void setLastSyncedDateTime(String lastSyncedDateTime) {
        this.lastSyncedDateTime = lastSyncedDateTime;
    }

    @Override
    public Object clone() throws CloneNotSupportedException
    {
        return super.clone();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof ItemObject)) {
            return false;
        }

        ItemObject that = (ItemObject) o;

        if (checked != that.checked) {
            return false;
        }
        if (collapsed != that.collapsed) {
            return false;
        }
        if (dateStringPriority != that.dateStringPriority) {
            return false;
        }
        if (id != that.id) {
            return false;
        }
        if (itemOrder != that.itemOrder) {
            return false;
        }
        if (itemType != that.itemType) {
            return false;
        }
        if (parentId != that.parentId) {
            return false;
        }
        if (priority != that.priority) {
            return false;
        }
        if (projectId != that.projectId) {
            return false;
        }
//        if (children != null ? !children.equals(that.children) : that.children != null) {
//            return false;
//        }
        if (!content.equals(that.content)) {
            return false;
        }
//        if (dateString != null ? !dateString.equals(that.dateString) : that.dateString != null) {
//            return false;
//        }
//        if (dueDate != null ? !dueDate.equals(that.dueDate) : that.dueDate != null) {
//            return false;
//        }
//        if (lastSyncedDateTime != null ? !lastSyncedDateTime.equals(that.lastSyncedDateTime) : that.lastSyncedDateTime != null) {
//            return false;
//        }
//        if (path != null ? !path.equals(that.path) : that.path != null) {
//            return false;
//        }
//        if (recurrence != null ? !recurrence.equals(that.recurrence) : that.recurrence != null) {
//            return false;
//        }

        return true;
    }
}
